package cn.cdqf.manager.controller;

import cn.cdqf.global.common.ResultResponse;
import cn.cdqf.manager.controller.validator.BindingResultUtil;
import cn.cdqf.manager.param.CouponTemplateParam;
import cn.cdqf.manager.service.CouponTemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@Api("优惠券模板接口")
@RestController
public class CouponTemplateController {

    @Autowired
    private CouponTemplateService couponTemplateService;

    //srpingmvc接收参数只能有一个@requesbody,而且不能和requestparam共用
    @PostMapping("couponTemplate")
    @ApiOperation("增加优惠券模板")
    public ResultResponse addCouponTemplate(@ApiParam(value = "优惠券logo",required = true) MultipartFile multipartFile,
            @ApiParam("模板参数") @Validated  CouponTemplateParam couponTemplateParam, BindingResult bindingResult){
        BindingResultUtil.checkBindingResultUtil(bindingResult);
        //当前操作人员
        couponTemplateService.insert(couponTemplateParam);
        return ResultResponse.success();
    }
}
